<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>朝阳区 Prism</title>
    <style>
        html,
        body,
        #container {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
<script src="https://webapi.amap.com/maps?v=1.4.14&key=ecfb869b5b761758cecc1381d377e4c6&plugin=Map3D,AMap.DistrictSearch"></script>
<script src="https://webapi.amap.com/loca?v=1.3.0&key=ecfb869b5b761758cecc1381d377e4c6"></script>
<script src="https://a.amap.com/Loca/static/mock/heatmapData.js"></script>
<script>
    var map = new AMap.Map('container', {
        viewMode: '3D',
        pitch: 50,
        zoom: 11,
        center: [121.4899200000, 30.9208500000]
    });

    // 设置光照
    map.AmbientLight = new AMap.Lights.AmbientLight([1, 1, 1], 0.5);
    map.DirectionLight = new AMap.Lights.DirectionLight([0, 0, 1], [1, 1, 1], 1);

    var object3Dlayer = new AMap.Object3DLayer();
    map.add(object3Dlayer);

    new AMap.DistrictSearch({
        subdistrict: 0,   //返回下一级行政区
        extensions: 'all',  //返回行政区边界坐标组等具体信息
        level: 'city'  //查询行政级别为 市
    }).search('奉贤区', function (status, result) {
        var bounds = result.districtList[0].boundaries;
        var height = 5000;
        var color = '#0088ffcc'; // rgba
        var prism = new AMap.Object3D.Prism({
            path: bounds,
            height: height,
            color: color
        });

        prism.transparent = true;
        object3Dlayer.add(prism);

        var text = new AMap.Text({
            text: result.districtList[0].name + '</br>(' + result.districtList[0].adcode + ')',
            verticalAlign: 'bottom',
            position: [116.528261, 39.934313],
            height: 5000,
            style: {
                'background-color': 'transparent',
                '-webkit-text-stroke': 'red',
                '-webkit-text-stroke-width': '0.5px',
                'text-align': 'center',
                'border': 'none',
                'color': 'white',
                'font-size': '24px',
                'font-weight': 600
            }
        });

        text.setMap(map);
    });
    
    var layer = new Loca.HeatmapLayer({
        map: map,
    });

    var list = [];
    var i = -1, length = heatmapData.length;
    while (++i < length) {
        var item = heatmapData[i];
        list.push({
            coordinate: [item.lng, item.lat],
            count: item.count
        })
    }

    layer.setData(list, {
        lnglat: 'coordinate',
        value: 'count'
    });

    layer.setOptions({
        style: {
            radius: 30,
            color: {
                0.5: '#2c7bb6',
                0.65: '#abd9e9',
                0.7: '#ffffbf',
                0.9: '#fde468',
                1.0: '#d7191c'
            }
        }
    });

    layer.render();

</script>
</body>
</html>